<template>
  <div style="width:100%">
    <el-form ref="dataForm" inline label-width="120px">
      <el-form-item prop="name">
        <el-input v-model="name" placeholder="姓名"></el-input>
      </el-form-item>
    </el-form>
    <el-table stripe :data="tableList" border style="width: 100%;" size="mini">
      <el-table-column
        prop="name"
        sortable
        header-align="center"
        align="center"
        width="180px"
        label="姓名"
      ></el-table-column>
      <el-table-column prop="departName" sortable header-align="center" align="center" label="部门"></el-table-column>
      <el-table-column prop="phone" sortable header-align="center" align="center" label="手机号"></el-table-column>
      <el-table-column
        prop="roleName"
        sortable
        header-align="center"
        align="center" 
        label="角色"
      ></el-table-column>
      <el-table-column
        v-if="isCar"
        prop="licenseNum"
        sortable
        header-align="center"
        align="center"
        label="车牌"
      ></el-table-column>
       
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dataList: [],
      name: "",
      dataTitle: "",
      isCar: false
    };
  },
  computed: {
    tableList() {
      let list = [];
      if (!this.name) {
        list = this.dataList;
      } else {
        list = this.dataList.filter(item => {
          return item.name.indexOf(this.name) !== -1;
        });
      }
      return list;
    }
  },
  created() {
    //

    let queryO = this.$route.query;
    let id = queryO.id;
    let type = queryO.type;
    let url = "/employee/MidList";
    if (type == "0") {
      url = "/car/MidList";
      this.isCar=true;
    }

    this.$http({
      url: this.$http.adornUrl(url),
      method: "POST",
      data: this.$http.adornData({ mid: id })
    }).then(({ data }) => {
      if (data.code == "0") {
        this.dataList = data.list;
      } else {
      }
    });
  }
};
</script>

<style>
</style>